package engine.newUi
{
	import com.greensock.TweenLite;
	import com.greensock.easing.Linear;
	
	import engine.control.loading.MultLoader;
	import engine.data.BindManage;
	import engine.data.ModelLocator;
	import engine.data.Record;
	import engine.flag.PlayerActionFlag;
	import engine.flag.ResourcesPath;
	import engine.logic.LogSendLogic;
	import engine.logic.SceneTransfer;
	import engine.logic.login.PlayCDTimerLogic;
	import engine.net.event.CustomMsgEvent;
	import engine.net.messages.CustomToClientFlag;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.mgr.SystemSender;
	import engine.tip.TipsMainLogic;
	import engine.ui.AlertUI;
	import engine.ui.CDClearTypeUI;
	import engine.ui.MainUIManager;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.events.TextEvent;
	import flash.events.TimerEvent;
	import flash.filters.GlowFilter;
	import flash.geom.Point;
	import flash.utils.Timer;
	
	import newx.StageInfo;
	import newx.com.ResManager;
	import newx.com.config.StaticIni;
	import newx.com.control.window.NxWindowDragType;
	import newx.com.loader.SwfLoader;

	public class TourLogic
	{
		public static var _self:TourLogic ; 
		public static function getInstance():TourLogic
		{
			if(_self==null)
			{
				_self = new TourLogic(); 
			}
			return _self ; 
		}
		public var _ui:TourUI ; 
		private const DICE_SPEED:Number=400;
		private var _model:ModelLocator;
		/**"任务模型对象*/
		private var _roleModel:MovieClip;
		/**"开始游历"按钮是否可以点击*/
		private var _isStop:Boolean	=	false;
		// 坐标数组
		private var pointArr:Array ;
		//记入我当前走了几个格子
		private var pointCount:int = 0  ; 
		//判断
		private var _isOK:Boolean ;
		//服务端 传过来的点数
		private var count:int ;
		//场景
		public var SceneMC:MovieClip ; 
		//时间控制 骰子
		private var nxTimer:Timer ; 
		// 进度条
		private var loadCount:int ; 
		//
		private var _indexOneCount:int = -1 ; 
		//
		private var _indexTwoCount:int = -1 ; 
		//
		private var _indexThreeCount:int = -1 ; 
		//
		private var _indexFourCount:int  = -1 ; 
		//
		private var _indexFiveCount:int = -1 ; 
		//
		private var _indexSixCount :int  =-1 ; 
		//7
		private var _indexSevenCount:int = -1 ; 
		//8
		private var _indexEight:int	= -1 ; 
		
		private var _bingManage:BindManage;
		//抛掷次数
		private var _indexTour:int ; 
		//一天可以抛10次
		private var _tourAll:int  ; 
		//只获取一次位置
		private var _isTure:Boolean=true ; 
		//抛掷骰子个数
		private var  _TourCount:uint ; 
		//
		private var _onePoint:int ; 
		private var _twoPoint:int ; 
		private var _threePoint:int ; 
		//
		private var _vipLevel:int ; 
		//日志信息 array
		private var _strArray:Array ; 
		//倒计时字符串
		private var _timeStr:String; 
		// 元宝
		private var _magicCoin:int ; 
		//
		private var _CD:Boolean =true ; 
		private var _cdTime:int	=	0;
		//消除CD
		private var  _col:int ; 
		//CD 消除元宝数
		private var _CDMagicCoin:int ; 
		//
		private var _windowIsOk:Boolean; 
		//选择 骰子个数
		private var _ClickCount:Boolean= true; 
		//当玩家走到指定的位置才可以在去点骰子
		private var _ludoBoolean:Boolean=true;
		//
		private var _num:int; 
		//是否游历了一圈
		private var _okAndNo:Boolean =false ; 
		//随机坐标数组
		private var _arrPoint:Array ; 
		//移动最终 目标
		private var _point:Array ;
		//停止 骰子转动
		private var _stopRun:uint = 0  ; 
		//
		private var _twoPointArr:Array
		
		private var twoPoint:Point ;
		private var threePoint:uint ;
		private var _sprite:Sprite ;

		//获取是否
		private var _isGoods:Boolean=false ;
		//记录特效字体什么时候消失
		private var _time:int  ;
		//
		private var _timer:Timer ; 
		//在四个随机点 不显示 头顶的 艺术字
		private var _showWord:uint ;
		
		//任务有没有完成,色子是否可以点击
		private var _taskIsOk:Boolean = true ;
		private var _getRewardStr:String=""; 
		/**接受任务等于true*/
		private var _clearStr:Boolean =false ; 
		private const SCALE:Number=0.5;
//		private var _str:String= "" ;
		//任务描述
		private var _taskArr:Array ;
		private var _isTourTask:Boolean
		/***界面开关和任务接受*/
		private var _openAndOn:Boolean=false ;
		/**放弃任务不弹提示框*/
		private var _tip:Boolean=true;
		/**地名提示框*/
		private var _cityName:String="";
		/**可选骰子个数*/
		private var objSz:Object ; 
		//显示骰子的个数
		private var twoNeed:int  ;
		private var threeNeed:int ; 
		public function TourLogic()
		{
			
		}
		public function Init():void
		{
			_TourCount =1 ; 
			_tourAll =10 ; 
			_ui= TourUI.getInstance(); 
			_model=ModelLocator.getInstance();
			_bingManage = BindManage.getInstance();	
			PlayCDTimerLogic.getInstance().resgis(10,checkCDTimer);
			_strArray = new Array();
			pointArr= new Array(); 
			_sprite = new Sprite () ;

			
			_ui.windowBG.dragSpaceType	=	NxWindowDragType.Window_NONE;
			//界面打开时 消息
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_WORLD_TRAVEL_INFO),Openinter);
			//抛 骰子 返回消息
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_BEGIN_WORLD_TRAVEL),startBtnInfo);
			// 游历一圈 特效显示
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_WORLD_TRAVEL_Prize),getLog);
			//每次消CD  花的元宝数
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_SEND_CLEAR_CD_CONSUME),getMagicCoinCD);
			//每次请求 CD 时间
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_SEND_CD_TIME),getCDTimer);
	
			_ui.tour_1.visible =false ;
			_ui.tour_2.visible =false ;
			_ui.tour_3.visible =false ;
			
			_ui.tour_5.visible =false ;
			_ui.tour_6.visible =false ;
			
			_ui.clearcd.visible = false ; 
			
			_ui.tour_4.buttonMode =true ;
			_ui.tour_5.buttonMode =true ;
			_ui.tour_6.buttonMode =true ;
			
			_ui.tour_4.x  	=453;
			_ui.tour_4.y 	=325	;
			_ui.tour_1.x	=453
			_ui.tour_1.y	=325;	
			
			_arrPoint = [[453,250],[340,410],[340,300],[600,406],[590,260]]; 
			_point = [[453,325],[360,396],[590,396]]; 
			_twoPointArr = [[362,331],[520,331]]  ; 
			
			//
			_ui.mc_tx.movie.stop();
			_ui.mc_tx.visible =false ;
			_ui.goods_tx["tg"]=_ui.goods_tx.getChildAt(0);
			_ui.goods_tx["tg"].addFrameScript(_ui.goods_tx["tg"].totalFrames-1,goodsMC);
			
			_ui.giveup_btn.visible = false ; 
			_ui.finish_btn.visible = false ;
			_ui.finishrw_btn.visible =false;  
			for(var j:uint=0 ; j<_TourCount ; j++)
			{
				_ui["tour_"+(j+4)].visible= true ; 
			}
			topIcon();
			_indexSevenCount = _bingManage.BindRecord(_model.scene,"WorldTravelTaskRec",addTask,removeTask);
			
			objSz = StaticIni.getIniObj("WorldTravel_Need");
			twoNeed			= 	objSz["two_btnVIPLevel"]	
			threeNeed 		=	objSz["three_btnVIPLevel"]	 
		}
		public function BeforeShow():void
		{
			
			_indexSevenCount=BindManage.getInstance().UnbindRecord("WorldTravelLogRec",_indexSevenCount);
		
			_taskIsOk=true ; 
			//请求CD 的时间
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST_CD_TIME,10);
			
			_isOK= true ;
			//热区
			_sprite.buttonMode = true ; 
			_sprite.graphics.beginFill(0x000000,0);
			_sprite.graphics.drawRect(280,270,420,220);
			_sprite.graphics.endFill();
	
			_ui.goods.visible =false ;
			goodsMC();
			initScene();
			SitCrossleggedUI.getInstance().visible =false ; 
			_windowIsOk =true;
			
			
		}
		/**
		 * 
		 * 
		 */		
		public function ShowUI():void
		{
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_ENTRY_CLONE_PLAYER_ROOM)
		}
		private function addListener ():void
		{
			
			_sprite.addEventListener(MouseEvent.CLICK , startBtnHandler);
		
			SceneMC["one_btn"].addEventListener(MouseEvent.CLICK,onebtnHandler);
			SceneMC["two_btn"].addEventListener(MouseEvent.CLICK,twobtnHandler);
			SceneMC["three_btn"].addEventListener(MouseEvent.CLICK,threebtnHandler);
		
			_ui.closeBtn.addEventListener(MouseEvent.CLICK,closeHandler);
			_ui.clearcd.addEventListener(MouseEvent.CLICK,clearcdHandler);
			
			addTipsListener(SceneMC) ;
			addGlowListener(_sprite);
			
			SceneMC["text_1"].addEventListener(TextEvent.LINK,linkHandle); 
			
			_ui.finish_btn.addEventListener(MouseEvent.CLICK,finishTaskHandler);
			_ui.giveup_btn.addEventListener(MouseEvent.CLICK,giveUpTaskHandler);
			_ui.finishrw_btn.addEventListener(MouseEvent.CLICK,finishrwHandler);
			
			
		}
		/**
		 *  Text超链接 
		 * @param val
		 * 
		 */		
		private function linkHandle(e:TextEvent):void
		{
			_getLink(e.text);
		}
		private function _getLink(str:String):void
		{
			_ui.hide();
			switch(str)
			{
//				case "琅嬛福地":
//					DiceLogic.getInstance().ui.showOrHide();
//					break ;
//				case "强化":
//					EquipModifiedUI.getInstance().showOrHide();
//					
//					break ; 
//				case "洗髓":
//						
//					break ;
				case (StaticIni.getSwfLangStr("Href_600302")):
					StatusShopUI.getInstance().showOrHide();
					break ;
				case (StaticIni.getSwfLangStr("Href_600402")):
					var str:String= _model.scene.Role.getPlayerGuild();
					if(str=="")
					{
						FamilyLogic.getInstance().ui.showOrHide();
					}else
					{
						//进入总坛
						SystemSender.getInstance().CustomMsg(
							CustomToServerFlag.CLIENT_CUSTOMMSG_PLAYER_GUILD_SCENE);
					}
					break ;
				case (StaticIni.getSwfLangStr("Href_600101")):
					TopPlayerLogic.getInstance().spBtnHandler();
					break ;
				case (StaticIni.getSwfLangStr("Href_600402")):
					break ; 
				case (StaticIni.getSwfLangStr("Href_600301")):
					_ui.hide();
					break ; 
			}
			if(ActivitesGroupLogic.getInstance().changeMax<=0&&str=="75041004")
			{
				
			}else
			{
				SceneTransfer.getInstance().tranferTo(str);
			}
			
		}
		/**
		 * 
		 * @param target
		 * 
		 */		
		private function addTipsListener( target : DisplayObject ):void
		{
			target.addEventListener( MouseEvent.MOUSE_OVER, onShowTips );
			target.addEventListener( MouseEvent.MOUSE_OUT, onHideTips ); 
		}
		/**
		 *	发光 效果 
		 * @param target
		 * 
		 */		
		private function addGlowListener( target : DisplayObject ):void
		{
			target.addEventListener( MouseEvent.MOUSE_OVER, onShowGlow);
			target.addEventListener( MouseEvent.MOUSE_OUT, onHideGlow); 
		}
		public function AfterHide():void
		{
			if(_ui == null)return ; 
			unbind();
			MainUIManager.getInstance().intoScene();
			SitCrossleggedUI.getInstance().visible =true; 
			_ui.mc_tx.movie.stop();
			_ui.mc_tx.visible = false;
			SitAlerUI.getInstance().checkBtn.visible=true;
			SitAlerUI.getInstance().label2.htmlText = "下次不在提示";
			SitAlerUI.getInstance().label2.x = 152 ; 
		}		
		//开始之------------------------------------------骰子
		private function startBtnHandler(e:MouseEvent):void
		{
			if(_indexTour<_tourAll&&_taskIsOk)//&&_CD==true
			{
				if(_ludoBoolean==true)
				{
					_openAndOn=false; 
					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_WORLD_TRAVEL_BEGIN,_TourCount);
				}
				
			}else 
			{
				if(_indexTour==_tourAll)
				{
				
					NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("UIString_1000318")); 
					
				}
//				else if (_taskIsOk==true)//_CD==false&&
//				{
//					NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("UIString_1000287")); 
//				}
			}
		}
//		 *  回调函数
//			返回练功房的CD时间，等级信息
//			val cd时间，Array 数据
//		 * @param val
//		 * @param arr 第一个 时间
		public function checkCDTimer(val:int,col:int):void
		{
//			_cdTime	=	val;
//			_col=col
//			if(val==0)
//			{
//				topIcon();
////				ActivitesGroupLogic.getInstance().addEffect(11);
//				_ui.clearcd.visible =false ; 
//				_CD= true; 
//				_ui.label_2.visible =false ; 
//				return ;
//			}else
//			{
//				ActivitesGroupLogic.getInstance().removeEffect(11);
//				_ui.clearcd.visible =true ; 
//				_CD= false ; 
//				_ui.label_2.visible =true;
//				_timeStr=PlayCDTimerLogic.getInstance().getTimerStr(val);
//				_ui.label_2.htmlText="冷却时间"+_timeStr ;
//			}
		}

		// 关闭窗口-------------------------------------按钮
		private function closeHandler(e:MouseEvent):void
		{
			if(SitAlerUI.getInstance().created==true)
			{
				SitAlerUI.getInstance().hide();
			}
			_windowIsOk = false ;
			_ui.hide();
			AlertUI.hideAlert();
		}
		/**
		 * 加载人物模型 
		 */		
		private function loadModel():void
		{
//			if(_roleModel==null)
//			{
				var swfURL:String	=	ResourcesPath.getRoleModel(_model.scene.Role);
				SwfLoader.StartLoad(swfURL, null, loadOver);
//			}
//			else
//			{
//				
//			}
		}
		/**
		 * 加载人物
		 * @param mc 
		 * @param pl
		 * 
		 */		
		private function loadOver(mc:MovieClip,pl:Array):void
		{
			if(mc)
			{
				if(_roleModel!=null&&_roleModel.stage)
				{
					_roleModel.parent.removeChild(_roleModel);
					
				}
				mc.scaleX	=	mc.scaleY	=	SCALE;
				
				_roleModel	=	mc;
				
				if(_roleModel.numChildren == 1 && _roleModel.totalFrames == 1 )
				{
					_roleModel = _roleModel.getChildAt( 0 ) as MovieClip;
				}else
				{
					_roleModel = ResManager.copy( _roleModel ) as  MovieClip;
				}
				if(pointCount>20)
				{
					_roleModel.x=pointArr[pointCount%20][0];
					_roleModel.y=pointArr[pointCount%20][1];
				}else
				{
					_roleModel.x=pointArr[pointCount][0];
					_roleModel.y=pointArr[pointCount][1];
				}
				
				
				
				SceneMC.addChild(_roleModel);
				SceneMC.addChild(_ui.clearcd);
				SceneMC.addChild(_ui.goods_tx);
				
				
				modelStop();
			}
			else
			{
				//trace("Error~WorldMapLogic.loadOver(mc, pl)没人物模型");
				
			}
		}
		/**
		 * 
		 * @param point
		 * 跑到目标点--------------------------------
		 */		
		private function runToPoint(point:Point):void
		{
			
			
			modelRun(point);
			
			TweenLite.to(_roleModel,1,{x:point.x,y:point.y,onComplete:endRun,ease:Linear.easeNone});
			function getDistance():Number
			{
				var p:Point=new Point(_roleModel.x,_roleModel.y);
				return Point.distance(p,point);
			}
		}
		/**
		 * 
		 * 走完一个坐标在走另一个坐标
		 * 如果就就给玩家发奖励
		 */		
		private function endRun():void
		{
			
				count--;
				if(count>=0)
				{
					
					pointCount++;
					if(count>=1)
					{
						runToPoint(movieArea());
					}else 
					{
						// 在这里加 日志 和 收到奖励特效
						modelStop();
						TourLog(true);
						taskAccept() ; 
						_openAndOn=true; 
						createTxAndRe();
						loadBar(loadCount);
						playWeekTx();
						return ;
					}
					
				}else
				{
					modelStop();
					return ;
				}
		}
		/**
		 * 
		 * @param point 接受任务
		 * 
		 */		
		 private function rewardFaceAndTourFace():void
		 {
			 
			 if(SceneMC==null)return  ; 
			 if(_clearStr==true)
			 {
				 
				 
				 if(_taskArr[2]>=_taskArr[3])
				 {
					 _taskArr[2]=_taskArr[3] ; 
					 Createbtn(true);
				 }else
				 {
					 Createbtn(false);
				 }
				 
				 for(var i:uint=0 ; i<_TourCount ; i++)
				 {
					 _ui["tour_"+(i+4)].visible= false ; 
				 }
				 _taskIsOk=false ; 
				 SceneMC["m_1"].gotoAndStop(2);
				 SceneMC["m_2"].gotoAndStop(2);
				 SceneMC["m_3"].visible = true ; 
				 SceneMC["text_0"].visible=true ;
				 SceneMC["mc_task"].visible=true ;
				 
				 SceneMC["m_2"].y =380 ;
				 SceneMC["text_1"].y =401
					 
				 SceneMC["m_3"].y =480 ; 
				 SceneMC["text_0"].y=500;
				 //任务描述
				 SceneMC["text_2"].htmlText=StaticIni.getSwfLangStr("WttDes_"+_taskArr[0]);
				 //完成条件
				 SceneMC["text_1"].htmlText=StaticIni.getSwfLangStrVar("WttCondition_"+_taskArr[0],[_taskArr[3],_taskArr[2],_taskArr[3]]);
				 //任务奖励
				 SceneMC["text_0"].htmlText=StaticIni.getSwfLangStrVar("WttPrize",[StaticIni.getSwfLangStr("Capital_"+_taskArr[4]),_taskArr[5]]);
				 //	 _clearStr = true  ; 
				 _sprite.buttonMode = false ; 
				 

			 }else
			 {
				 SceneMC["m_1"].gotoAndStop(1);
				 SceneMC["m_2"].gotoAndStop(1);
				 SceneMC["m_3"].visible = false; 
				 SceneMC["text_0"].visible=false ;
				 SceneMC["mc_task"].visible=false ;
				 SceneMC["text_2"].htmlText=StaticIni.getSwfLangStr("UIString_1000262");
				 SceneMC["text_0"].htmlText="" ;
				 SceneMC["text_1"].htmlText=_getRewardStr;
				 
				 for(var j:uint=0 ; j<_TourCount ; j++)
				 {
					 _ui["tour_"+(j+4)].visible= true ; 
				 }
				 _taskIsOk=true ; 
				 _sprite.buttonMode = true; 
				 _ui.giveup_btn.visible = false ; 
				 _ui.finish_btn.visible = false ;
				 _ui.finishrw_btn.visible =false;  
				 SceneMC["m_2"].y =430 ;
				 SceneMC["text_1"].y =455;
				 
				 SceneMC["m_3"].y =520 ; 
				 SceneMC["text_0"].y=545;
			 }
			
		 }
		 /**
		  * 判断--按钮
		  * 
		  */
		 private function Createbtn(isOk:Boolean):void
		 {
			 if(_vipLevel>=3)
			 {
				 if(isOk==true)
				 {
					 _ui.finishrw_btn.x =1160  ; 
					 _ui.finishrw_btn.y =600  ; 
					 _ui.finishrw_btn.visible = true ; 
					 _ui.finish_btn.visible = false; 
					 _ui.giveup_btn.visible = false; 
					 
				 }else
				 {
					 _ui.finish_btn.visible = true; 
					 
					 _ui.giveup_btn.visible = true; 
					 
					 _ui.giveup_btn.x =1120 ; 
					 _ui.giveup_btn.y =600  ; 
					 
					 _ui.finish_btn.x =1010 ; 
					 _ui.finish_btn.y =600  ; 
				 }
				 
			 }else
			 {
				 if(isOk==true)
				 {
					 _ui.finishrw_btn.x =1050 ; 
					 _ui.finishrw_btn.y =600  ; 
					 _ui.finishrw_btn.visible = true ; 
					 _ui.giveup_btn.visible = false ; 
					 
				 }else
				 {
					 _ui.giveup_btn.x =1050  ; 
					 _ui.giveup_btn.y =600  ; 
					 _ui.giveup_btn.visible = true ; 
				 }
				 
				 
				 
//				 _ui.finish_btn.visible = false;  
			 }
		 }
		/**
		 * 
		 * @param point 初始化游历日志
		 * tips 初始化的时候不弹3秒框
		 * 
		 */		 
		 private function TourLog(tips:Boolean):void
		 {
			 if(SceneMC==null)return ;
			 SceneMC["text_1"].htmlText="";
			 if(_strArray==null||_strArray.length==0)return;
			 if(_strArray.length>4)
			 {
				
				 var i:uint = 0; 
				 for(i;i<5 ; i++)
				 {
					 
					 SceneMC["text_1"].htmlText+=_strArray[(_strArray.length-1)-i].toString();
				 } 
				 
			 }else
			 {
				 for(var j:uint = 0 ;j<_strArray.length;j++)
				 {
					 SceneMC["text_1"].htmlText+=_strArray[j].toString();
				 }
			 }
			 _getRewardStr=SceneMC["text_1"].htmlText;
			if(tips==true&&_clearStr==false)
			{
				if(_tip==true)
				{
					warning(_strArray[_strArray.length-1].toString());
				}else
				{
					_tip=true;
				}
				
			}
		 }
		/**
		 *玩家跑动行为 
		 * 
		 */		
		private function modelRun(point:Point):void
		{
			if(point.x < _roleModel.x)
			{
				_roleModel.scaleX	=	-0.5;
			}
			else
			{
				_roleModel.scaleX	=	0.5;
			}
			_roleModel.gotoAndPlay(PlayerActionFlag.Run);
			
		}
		/**
		 *玩家 站立行为 
		 * 
		 */		
		private function modelStop():void
		{

			_ludoBoolean= true ;
			_roleModel.gotoAndPlay(PlayerActionFlag.NormalWait);
			_roleModel.scaleX =  _roleModel.scaleY = SCALE ;

			
		}
		/**
		 *获取游历物品 
		 * @return 
		 * 
		 */		
		private function showGoods(e:TimerEvent):void
		{
			
			_time++;
			if(_time<55&&_time>18)
			{
				if(_showWord>=5)
				{
					_ui.goods.visible = false;
				}else
				{
					_ui.goods.visible = true;
				}
				 
			
				_ui.goods.y-=0.5;
				
			}else if(_time<=18)
			{
				
			}
			else
			{
				e.target.stop();
				_ui.goods.visible = false ;
				_time = 0 ;
			}
		
		}
		/**
		 * 游历范围 
		 * @return 
		 * 
		 */		
		private function movieArea():Point
		{
			var arr:Array=pointArr[(pointCount+1)%20] ;
			var po:Point	=	new Point(arr[0],arr[1]);
			return po
		}
		/**
		 * 
		 *点打开界面 服务器返回来的消息 
		 */		
		private function Openinter(e:CustomMsgEvent):void
		{
			//初始化 所有的奖励
			var i:int = 0 ; 
			for(i ; i<20;i++)
			{

				if(e.pList[i*2] == 5 || e.pList[i*2] == 0 || e.pList[i*2] ==10 || e.pList[i*2] == 15)
				{
					SceneMC["label_"+i].visible= false ; 
				}else
				{
					SceneMC["label_"+i].gotoAndStop(e.pList[i*2]);
					SceneMC["label_"+i].visible= true ; 
				}
				
			}
		}
		/**
		 * 点开始按钮 服务器返回来的消息 
		 * 
		 */		
		private function startBtnInfo(e:CustomMsgEvent):void
		{
			count = e.pList[0] + e.pList[1] + e.pList[2];
			
			if(count == 0)
			{
				return ; 
			}
			_onePoint 	= e.pList[0];
			_twoPoint 	= e.pList[1];
			_threePoint = e.pList[2];
			
			_ClickCount = false;
			_isStop = true ; 
			showTourCount(_TourCount);
			
			var i :uint = 0; 
			for(i;i<_TourCount;i++)
			{
				getRandom(i);
			}
			_ludoBoolean = false ; 
			
			_isGoods =true; 
			
		}
		private function getRandom( value:int ):void
		{
			
				var mc:MovieClip = _ui["tour_"+(value+1)] as MovieClip;
				mc["end"] = value ;
				var val:int  = Math.random()*5
				var val2:int	=	getDifferentPoint(val,mc["onePoint"]);
				twoPoint=movieTour(val2) ;
				mc["onePoint"] 	= val2;
				mc["realPoing"]	= new Point(mc.x,mc.y);
				var time:Number=Point.distance(mc["realPoing"],twoPoint)/getSpeed(0);
				TweenLite.to(mc,time,{x:twoPoint.x,y:twoPoint.y,onComplete:endTour,onCompleteParams:[mc],ease:Linear.easeNone});
			
		}
		private function getDifferentPoint(value:int,onePoint:int):int
		{
			if(value == onePoint)
			{
				var val:int =Math.random()*5
				return	 getDifferentPoint(val,onePoint);
			}
			onePoint = value
			return onePoint;
		}
		private function tourMoviePoint(value:int):void
		{
			if( value == 1 )
			{
				
				function getDistance():Number
				{
					var p:Point=new Point(_ui.tour_1.x,_ui.tour_1.y);
					return Point.distance(p,twoPoint);
				}
			}else if (value==2)
			{
				
			}
		}
		private function endTour(mc:MovieClip):void
		{
				var timer:int = mc["time"] ; 
				timer++; 
				mc["time"] = timer ; 
				var mc :MovieClip =  mc as MovieClip ; 
				var val:int  = Math.random()*5
				var val2:int	=	getDifferentPoint(val,mc["onePoint"]);
				twoPoint=movieTour(val2) ;
				mc["onePoint"]=val2;
				var speed:Number=getSpeed(timer);
				var time:Number=Point.distance(mc["realPoing"],twoPoint)/speed;
				if(time<=0.2)
				{
					time+=0.3
				}else if(time<0.5&&time>0.2)
				{
					time+=0.1
				}
				mc["realPoing"]=twoPoint;
				if(mc["time"]>=3)
				{
					twoPoint=movieEndTour(int(mc["end"])) ;
					TweenLite.to(mc,time,{x:twoPoint.x,y:twoPoint.y,onComplete:MovieendTour,onCompleteParams:[mc],ease:Linear.easeNone});
				}
				else
				{
					TweenLite.to(mc,time,{x:twoPoint.x,y:twoPoint.y,onComplete:endTour,onCompleteParams:[mc],ease:Linear.easeNone});
				}
		}
		private function getSpeed(timer:int):Number
		{
			return DICE_SPEED-timer*50;
		}
		/**
		 *骰子 停止 
		 * @param mc
		 * 
		 */		
		private function MovieendTour(mc:MovieClip):void
		{
			
			mc["time"]= 0 ; 
			var count:int = int(mc["end"])
			_ui["tour_"+(count+4)].visible= true
			_ui["tour_"+(count+1)].visible= false ; 
			
			if(count==0)
			{
				_ui["tour_"+(count+4)]..gotoAndStop(_onePoint);
				
//				modelRun();
				//--------------------------------------------------
				runToPoint(movieArea());
				_ClickCount= true ;
				
			}else if (count==1)
			{
				_ui["tour_"+(count+4)]..gotoAndStop(_twoPoint);
			}else if(count==2)
			{
				_ui["tour_"+(count+4)]..gotoAndStop(_threePoint);
			}

		}
		/**
		 * 
		 * @param value 骰子的最终 位置
		 * @return 
		 * 
		 */		
		private function movieEndTour(value:int ):Point
		{	
			var arr:Array=new Array() ;
			
			if(_TourCount== 2)
			{
				arr =  _twoPointArr[value] ;
			}else
			{
				arr =  _point[value] ;
			}
			
			
			var po:Point	=	new Point(arr[0],arr[1]);
			return po;
		}
		/**
		 *骰子 移动坐标 
		 * @return 
		 * 
		 */		
		private function movieTour(value:int ):Point
		{
			var arr:Array=_arrPoint[value] ;
			
			var po:Point	=	new Point(arr[0],arr[1]);
			return po;
//			_ui.super.show()
		}
		
		
		
		/**
		 *初始化场景
		 * 
		 */		
		private function initScene():void
		{
			if(SceneMC==null)
			{
//				SwfLoader.StartLoad(StageInfo.swfResPath+"tour.swf", null, createScene);
//				MultLoader.getInstance().load([StageInfo.swfResPath + "tour.swf"],true,createScene);
				createScene();
				
			}else
			{
				_strArray.splice(0);
				addListener();
				bind();
//				TourLog(false);
				if(_openAndOn==true)
				{
					rewardFaceAndTourFace();
				}
//				else if(_openAndOn==false&&_clearStr==true)
//				{
//					for(var j:uint=0 ; j<_TourCount ; j++)
//					{
//						_ui["tour_"+(j+4)].visible= true ; 
//					}
//				}
				
				loadBar(loadCount);
				completeTask();
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_SHOW_WORLD_TRAVEL_UI);
			}
		}
		/**
		 * 生成场景
		 */		
		private function createScene():void
		{
			var mc:MovieClip=MultLoader.getInstance().getSourceByUrl(StageInfo.swfResPath + "tour.swf");
			
			if(mc)
			{
				
				
				mc.x=0
				mc.y=0;
				SceneMC= mc ; 
				_ui.windowBG.addChild(SceneMC);
				
				 
				var  j:int = 0 ; 
				for(j;j<5;j++)
				{
					SceneMC["box_"+j].visible =false ; 
					SceneMC["box_"+j].gotoAndStop (1) ;
					SceneMC["nxload_"+(j)].visible =false ;
				}
				
				var i :int =0 ;  
				for(i;i<20 ;i++)
				{
					pointArr.push([SceneMC["mc_"+i].x,SceneMC["mc_"+i].y]);
					SceneMC["label_"+i].visible = false ; 
				}
				
				SceneMC["one_btn"].gotoAndStop(2); 
				SceneMC["two_btn"].gotoAndStop(1); 
				SceneMC["three_btn"].gotoAndStop(1); 
				
				SceneMC.addChild(_ui.tour_1) ; 
				SceneMC.addChild(_ui.tour_2) ; 
				SceneMC.addChild(_ui.tour_3) ; 
				SceneMC.addChild(_ui.tour_4) ; 
				SceneMC.addChild(_ui.tour_5) ; 
				SceneMC.addChild(_ui.tour_6) ; 
				//
				SceneMC.addChild(_ui.label_1);
				SceneMC.addChild(_ui.label_2);
				//
				SceneMC.addChild(_ui.closeBtn);
				//
				
				//
				SceneMC.addChild(_ui.mc_tx);
				
			
				SceneMC["text_1"].text="" ; 
				SceneMC["text_2"].htmlText= StaticIni.getSwfLangStr("UIString_1000262");
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_SHOW_WORLD_TRAVEL_UI);
				
				addListener();
				
				SceneMC["m_1"].gotoAndStop(1);
				SceneMC["m_2"].gotoAndStop(1);
				SceneMC["m_3"].visible = false; 
				SceneMC["text_0"].visible=false ;
				SceneMC["mc_task"].visible=false ;
				
				_ui.giveup_btn.visible = false ; 
				_ui.finish_btn.visible = false ; 
				_ui.finishrw_btn.visible = false; 
				
				bind();
//				loadModel();
				
				//热区
				SceneMC.addChild(_sprite);
				SceneMC.addChild(_ui.goods);
//				SceneMC.addChild(_ui.goods_tx);
				SceneMC.addChild(_ui.finish_btn);
				SceneMC.addChild(_ui.giveup_btn);
				SceneMC.addChild(_ui.finishrw_btn);
				
				TourLog(false);
				rewardFaceAndTourFace();
				loadBar(loadCount);
				completeTask();
			}
		}
		/**
		 *时间控制骰子 
		 */		
//		private function timeHandler(e:TimerEvent):void
//		{
//			
//			nxTimer.stop(); 
//			modelRun();
//			//--------------------------------------------------
//			runToPoint(movieArea());
//			_ClickCount= true ;
			
//		}
		/**
		 * 
		 */		
		private function bind():void
		{
			if(_indexOneCount==-1)
			{
				// 抛骰子总的点数
				_indexOneCount = _bingManage.BindProp(_model.scene.Role,"WorldTravelPos",this,"getWorldTravelPos");
				
			}
			if(_indexTwoCount==-1)
			{
				// 添加投掷 次数
				_indexTwoCount = _bingManage.BindProp(_model.scene.Role,"WorldTravelMaxCountAdd",this,"getWorldTravelMaxCountAdd");
			}
			if(_indexThreeCount==-1)
			{
				//投掷的次数
				_indexThreeCount = _bingManage.BindProp(_model.scene.Role,"WorldTravelCount",this,"getWorldTravelCount");
			}
			if(_indexFourCount ==-1 )
			{
				_indexFourCount = _bingManage.BindProp(_model.scene.Role,"VIPLevel",this,"getVipLevel");
			}
			if(_indexFiveCount ==-1 )//表格
			{
				_indexFiveCount = _bingManage.BindRecord(_model.scene,"WorldTravelLogRec",addItem,removeItem);
			}
			if(_indexSixCount == -1 )
			{
				_indexFourCount = _bingManage.BindProp(_model.scene.Role,"MagicCoin",this,"getMagicCoin");
			}
			if(_indexSevenCount ==-1 ) //游戏任务表格
			{
				_indexSevenCount = _bingManage.BindRecord(_model.scene,"WorldTravelTaskRec",addTask,removeTask);
			}
			if(_indexEight ==-1)//人物模型 --改变
			{
				_indexEight = _bingManage.BindProp(_model.scene.Role,"Model",this,"getModel");
			}
		}
		private function unbind():void
		{
			if(_indexOneCount!=-1)
			{
				_indexOneCount=_bingManage.UnbindProp(_model.scene.Role,"WorldTravelPos",_indexOneCount);
			}
			if(_indexTwoCount!=-1)
			{
				_indexTwoCount=_bingManage.UnbindProp(_model.scene.Role,"WorldTravelMaxCountAdd",_indexTwoCount);
			}
			if(_indexThreeCount!=-1)
			{
				_indexThreeCount=_bingManage.UnbindProp(_model.scene.Role,"WorldTravelCount",_indexThreeCount);
			}
			if(_indexFourCount!=-1)
			{
				_indexFourCount=_bingManage.UnbindProp(_model.scene.Role,"VIPLevel",_indexFourCount);
			}
			if(_indexFiveCount!==-1)//移除表格
			{
				_indexFiveCount=BindManage.getInstance().UnbindRecord("WorldTravelLogRec",_indexFiveCount);
			}
			if(_indexSixCount!=-1)
			{
				_indexSixCount=_bingManage.UnbindProp(_model.scene.Role,"MagicCoin",_indexSixCount);
			}
			if(_indexSevenCount !=-1 ) //游戏任务表格
			{
//				_indexSevenCount=BindManage.getInstance().UnbindRecord("WorldTravelLogRec",_indexSevenCount);
			}
			if(_indexEight !=-1)
			{
				_indexEight = _bingManage.UnbindProp(_model.scene.Role,"Model",_indexEight);
			}
		}
		public function set getModel(value:int):void
		{
			loadModel();
		}
		/**
		 * 绑定属性的方法-----------// 抛骰子总的点数-------------------------------------------------------------------------------------- 
		 */	
		public function addItem(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
			
			var value:String  ; 
			var sss:String ; 
			var _str:String;
			var count:int  ;
			//游历一圈
			if(PropertiesValue[1]==99999)
			{
				count =PropertiesValue[0]/20;
				  
				_str = StaticIni.getSwfLangStrVar("UIString_1000288",[Math.abs(PropertiesValue[3]),StaticIni.getSwfLangStr("Capital_"+PropertiesValue[2])]);
				
			}else
			{
				//游历消息
				 count =PropertiesValue[0]%20+1;
				if(count>=10)
				{
					value =(count).toString();
				}else 
				{
					value="0"+(count).toString();
				}
				 sss = StaticIni.getSwfLangStr("Addressuistring_0"+value);
				
				 _str = StaticIni.getSwfLangStrVar("UIString_1000264",[sss,Math.abs(PropertiesValue[3]),StaticIni.getSwfLangStr("Capital_"+PropertiesValue[2])]);

			}
			
			_strArray.push(_str)
//			_showWord  = PropertiesValue[1] ; 

		}
		/**
		 * 游历的奖励特效 
		 * @return 
		 * 
		 */		
		private function createTxAndRe():void
		{
			//封装一个方法
			var timer:Timer = new Timer(0);
			timer.addEventListener(TimerEvent.TIMER,showGoods);
			
			var indeX:int ; 
			var indeY:int ; 
			
			if(_isGoods ==true)
			{
				
				indeX=_roleModel.x;
				indeY=_roleModel.y;
				
				_ui.goods_tx.x =_roleModel.x;
				_ui.goods_tx.y = _roleModel.y;
				_ui.goods_tx.visible =true  ;
				_ui.goods_tx["tg"].gotoAndPlay(1);
				
				
//				_ui.goods.x = _roleModel.x-15;
//				_ui.goods.y = _roleModel.y-180; 
//				
//				_ui.goods.visible= false;
//				
//				_ui.goods.gotoAndStop(_showWord);
			
				_isGoods =false ; 
			}
		}
		/**
		 * 
		 * @return 获取表格长度
		 * 
		 */		
		private function get WorldTravelLog():Array
		{
			return (_model.scene.GetPropertiesEx("WorldTravelLogRec") as Record).recArr;
		}
		
		private function goodsMC():void
		{
//		trace("TourLogic.goodsMC()");
			_ui.goods_tx.visible = false; 
			_ui.goods_tx["tg"].stop();
		}
		public function removeItem(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
			
		}
		public function set getWorldTravelPos(value:int):void
		{
			loadCount = value; 
			if(_isTure == true)
			{
				pointCount=loadCount%20
				_isTure= false ;
			}else if(_isTure==false&&value==0)
			{
				pointCount = 0 ;
				_roleModel.x=pointArr[0][0];
				_roleModel.y=pointArr[0][1];
				loadBar(loadCount);
				
			}
			
//			loadBar(loadCount);
		}
		/**
		 *	获得奖励添加的次数 
		 * @param value
		 * 
		 */		
		public function set getWorldTravelMaxCountAdd(value:int):void
		{
//			_tourAll+=value ; 
		}
		/**
		 * 抛掷的次数 
		 * @param value   ---------------
		 * 
		 */		
		public function set getWorldTravelCount(value:int):void
		{
			_indexTour=value; 
			_ui.label_1.htmlText = StaticIni.getSwfLangStrVar("UIString_1000203",[(_tourAll-_indexTour)]) ;
		}
		/**
		 * 
		 * @param value
		 * 获取 VIP 等级
		 * b
		 */		
		public function set getVipLevel(value:int):void
		{
			_vipLevel = value ; 
			if(_vipLevel<twoNeed)
			{
				SceneMC["one_btn"].visible = false ; 
				SceneMC["one"].visible = true ;
				
				SceneMC["two_btn"].visible = false ; 
				SceneMC["two"].visible = false ;
				SceneMC["three_btn"].visible = false ; 
				SceneMC["three"].visible = false ;
				
			}else if(_vipLevel>=twoNeed&&_vipLevel<threeNeed)
			{
				SceneMC["one_btn"].visible = true ; 
				SceneMC["one"].visible = true ;
				
				SceneMC["two_btn"].visible = true ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
				SceneMC["two"].visible = true ;
				SceneMC["three_btn"].visible = false ; 
				SceneMC["three"].visible = false ;
				
			}else
			{
				SceneMC["one_btn"].visible = true ; 
				SceneMC["one"].visible = true ;
				
				SceneMC["two_btn"].visible = true ; 
				SceneMC["two"].visible = true ;
				SceneMC["three_btn"].visible = true ; 
				SceneMC["three"].visible = true ;
			}
			
			
		}
		/**
		 * 进度条 
		 */	
		private function loadBar(value:int):void
		{
			var _Sval:int = value/20 ; 
			
			
			var _Zval:uint = value%20
			var  j:int = 0 ; 
			for(j;j<5;j++)
			{
				SceneMC["box_"+j].visible =false ; 
				SceneMC["box_"+j].gotoAndStop (1) ;
				SceneMC["nxload_"+(j)].visible =false ;
			}
			
			switch(_Sval)
			{
				case 0:

					SceneMC["box_0"].visible = true ; 
					SceneMC["nxload_0"].visible = true ; 
					SceneMC["nxload_0"].loadingLine.scaleX = (_Zval/20);
					break ;
				case 1:
					SceneMC["box_0"].gotoAndStop(2) ;
					getConpleteBar(1); 
					
					SceneMC["box_1"].visible = true ; 
					SceneMC["nxload_1"].visible = true ; 
					SceneMC["nxload_1"].loadingLine.scaleX = (_Zval/20);
					
					break ;
				case 2:
					SceneMC["box_1"].gotoAndStop(2);
					getConpleteBar(2); 
					
					SceneMC["box_2"].visible = true ;
					SceneMC["nxload_2"].visible = true ;
					SceneMC["nxload_2"].loadingLine.scaleX=(_Zval/20);
					

					break ;
				case 3:
					
					SceneMC["box_2"].gotoAndStop(2);
					getConpleteBar(3); 
					SceneMC["box_3"].visible = true ;
					SceneMC["nxload_3"].visible = true ;
					SceneMC["nxload_3"].loadingLine.scaleX=(_Zval/20);


					break ; 
				case 4:
					SceneMC["box_3"].gotoAndStop(2);
					getConpleteBar(4); 
					
					SceneMC["box_4"].visible = true ;
					SceneMC["nxload_4"].visible = true ;
					SceneMC["nxload_4"].loadingLine.scaleX=(_Zval/20);
					break ;
				case 5:
					SceneMC["box_4"].gotoAndStop(2);
					getConpleteBar(5);
					break ; 
				default:
					getConpleteBar(5);
					break;
			}
		}
		/**
		 *方法 
		 * @param num
		 * 
		 */		
		private function getConpleteBar(num:int):void
		{
			if(num ==  0 )return ; 
			var value:int = num ;
			var i :uint = 0 ;
			for(i;i<value ;i++)
			{
				SceneMC["box_"+i].gotoAndStop(2) ;
				SceneMC["box_"+i].visible = true ;
				SceneMC["nxload_"+i].visible= true ; 
				SceneMC["nxload_"+i].loadingLine.scaleX = 1 ; 
			}
 		}
		private function onebtnHandler(e:MouseEvent):void
		{
			if(_ClickCount==true&&_ludoBoolean==true)
			{
				
					SceneMC["one_btn"].gotoAndStop(2) ;
					SceneMC["three_btn"].gotoAndStop(1) ; 
					SceneMC["two_btn"].gotoAndStop(1) ; 
					_TourCount= 1 ; 
					_ui.tour_4.visible = true ;
					
					_ui.tour_5.visible = false ; 
					_ui.tour_6.visible = false ; 
					_ui.tour_4.x  = 453;
					_ui.tour_4.y  = 325	;
					_ui.tour_1.x  =453
					_ui.tour_1.y  =325;
					if(_clearStr==true)
					{
						_ui.tour_4.visible = false ;
					}
			}
		}
		private function twobtnHandler(e:MouseEvent):void
		{
			if(_ClickCount==true&&_ludoBoolean==true)
			{
				SceneMC["one_btn"].gotoAndStop(1) ; 
				SceneMC["two_btn"].gotoAndStop(2) ; 
				SceneMC["three_btn"].gotoAndStop(1) ; 
				_TourCount = 2 ; 
				_ui.tour_4.visible = true ;
				_ui.tour_5.visible = true ; 
				_ui.tour_6.visible =false ; 
				
				_ui.tour_4.x  = 362;
				_ui.tour_4.y  = 331	;
				_ui.tour_1.x	=362
				_ui.tour_1.y	=331;	
				
				_ui.tour_5.x  = 520;
				_ui.tour_5.y  = 331	;
				_ui.tour_2.x	=520
				_ui.tour_2.y	=331;	
				LogSendLogic.getInstance().btnClickNumSend(22811)
					
				if(_clearStr==true)
				{
					_ui.tour_4.visible = false ;
					_ui.tour_5.visible = false ; 
				}
			}
			
			
		}
		private function threebtnHandler(e:MouseEvent):void
		{
			if(_ClickCount==true&&_ludoBoolean==true)
			{
				SceneMC["three_btn"].gotoAndStop(2) ; 
				SceneMC["two_btn"].gotoAndStop(1) ; 
				SceneMC["one_btn"].gotoAndStop(1) ; 
				_TourCount =3 ; 
				_ui.tour_6.visible = true ; 
				_ui.tour_4.visible = true ; 
				_ui.tour_5.visible = true ; 
				
				_ui.tour_4.x  = 472;
				_ui.tour_4.y  = 283	;
				_ui.tour_1.x	=472
				_ui.tour_1.y	=283;	
				
				_ui.tour_5.x  = 360;
				_ui.tour_5.y  = 396	;
				_ui.tour_2.x	=360;
				_ui.tour_2.y	=396;	
				
				_ui.tour_6.x  = 590;
				_ui.tour_6.y  = 396	;
				_ui.tour_3.x	=590;
				_ui.tour_3.y	=396;	
				LogSendLogic.getInstance().btnClickNumSend(22812);
				if(_clearStr==true)
				{
					_ui.tour_4.visible = false ;
					_ui.tour_5.visible = false ; 
					_ui.tour_6.visible = false; 
				}
			}
		}
		/**
		 * 
		 */		
		private function showTourCount(value:int):void 
		{
			switch(value)
			{
				case 1:
					_ui.tour_1.visible =true ;
					_ui.tour_1.play();
					_ui.tour_4.visible=false ;
					break ; 
				case 2:
					_ui.tour_1.visible =true ;
					_ui.tour_1.play();
					_ui.tour_2.visible =true ;
					_ui.tour_2.play();
					_ui.tour_4.visible=false ; 
					_ui.tour_5.visible=false ; 
					break  ;
				case 3:
					_ui.tour_1.visible =true ;
					_ui.tour_1.play();
					_ui.tour_2.visible =true ;
					_ui.tour_2.play();
					_ui.tour_3.visible =true ;
					_ui.tour_3.play();
					
					
					_ui.tour_4.visible=false ; 
					_ui.tour_5.visible=false ; 
					_ui.tour_6.visible=false ; 
					break ; 
			}
		}
		/**
		 * 	
		 */		
		private function getLog(e:CustomMsgEvent):void
		{
			if(e.pList[0]==999)
			{
				_okAndNo = true ; 
			}
		}
		/**
		 * 
		 * 播放一周特效
		 */		
		private function playWeekTx():void
		{
			if(_okAndNo)
			{
				
				_ui.mc_tx.x=_roleModel.x; 	
				_ui.mc_tx.y=_roleModel.y-100;
				_ui.mc_tx.visible = true ; 
				_ui.mc_tx.movie.gotoAndStop(1);
				_ui.mc_tx.movie.play();
				_ui.mc_tx.movie.addFrameScript(_ui.mc_tx.movie.totalFrames-1,hideMC);
				
				_okAndNo =false ;
			}
		}
		private function hideMC():void
		{
			_ui.mc_tx.movie.stop();
			_ui.mc_tx.visible = false; 
		}
		public function set getMagicCoin(value:int):void
		{
			_magicCoin=value ; 
		}
		private  function clearcdHandler(e:MouseEvent):void
		{
			if(!CDClearTypeUI.getInstance().visible)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLEINT_CUSTOMMSG_REQUEST_CLEAR_CD_CONSUME,10);
			}
		}
		private function getMagicCoinCD(e:CustomMsgEvent):void
		{
//			trace("TourLogic.getMagicCoinCD(e)",e.pList);
			
		}
		private function onShowTips(evt : MouseEvent):void
		{

			var tip : String = "";
			
			switch( evt.target.name )
			{
				case "three_btn":
					 tip =StaticIni.getSwfLangStr("UIString_1000294") ;
					break ;
				case "two_btn":
					 tip =StaticIni.getSwfLangStr("UIString_1000293") ;
					break ;
				case "box_0":
					tip =StaticIni.getSwfLangStr("UIString_1000308") ;
					break ;
				case "box_1":
					tip =StaticIni.getSwfLangStr("UIString_1000309") ;
					break ;
				case "box_2":
					tip =StaticIni.getSwfLangStr("UIString_1000310") ;
					break ;
				case "box_3":
					tip =StaticIni.getSwfLangStr("UIString_1000311") ;
					break ;
				case "box_4":
					tip =StaticIni.getSwfLangStr("UIString_1000312") ;
					break ;
				case "mc_0":
					tip =StaticIni.getSwfLangStr("UIString_1000324") ;
					break;
				case "mc_5":
				case "mc_15":
					tip =StaticIni.getSwfLangStr("UIString_1000325") ;
					break;
				case "mc_10":
					tip =StaticIni.getSwfLangStr("UIString_1000326") ;
					break;
				default:
					if(_ui.clearcd.contains(evt.target as DisplayObject))
					{
						var needMoney:String	=	getNeedMagicCoin(_cdTime)
						tip =StaticIni.getSwfLangStrVar("UIString_1000095",[needMoney]) ;
					}else if(_ui.finish_btn.contains(evt.target as DisplayObject))
					{
						tip =StaticIni.getSwfLangStrVar("UIString_1000355",[5]) ;
					}
					break;
			}
			TipsMainLogic.instance.showString(tip);

		}
		private function onHideTips(evt:MouseEvent):void
		{
			TipsMainLogic.instance.hide();
		}
		private function getCDTimer(e:CustomMsgEvent):void
		{
			PlayCDTimerLogic.getInstance().resgis(10,checkCDTimer);
			
		}
		/**
		 * 返回所需要的龙金币
		 * @return
		 */
		private function getNeedMagicCoin(val:int):String
		{
			var minutes :Number;
			var seconds:Number;
			var needStr:String	=	"";
			minutes		=	Math.floor(val / 60);
			seconds		=	val  - minutes * 60;
			if (seconds > 0) 
			{
				minutes++;
			}
			needStr	=	String(1 * minutes);
			if(needStr>"5")
			{
				needStr = "5"; 
			}
			return needStr;
		}
		public function get windowOpen():Boolean
		{
			return _windowIsOk ; 
		}
		/**
		 * 鼠标移 上去骰子 发光
		 * @param e
		 * 
		 */		
		private function onShowGlow(e:MouseEvent):void
		{
			var glow:GlowFilter=new GlowFilter(0xFFFFFF);
			_ui.tour_4.filters=[glow];
			_ui.tour_5.filters=[glow];
			_ui.tour_6.filters=[glow];
			
		}
		/**
		 *  鼠标移除 出 不发光
		 * @param e
		 * 
		 */		
		private  function onHideGlow(e:MouseEvent):void
		{
			_ui.tour_4.filters=null;
			_ui.tour_5.filters=null;
			_ui.tour_6.filters=null;
		}
		public function addTask(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
			if(PropertiesValue.length!=0)
			{
				 _taskArr=PropertiesValue ; 
				_clearStr = true  ; 
				if(_taskArr[2]>=_taskArr[3])
				{
					ActivitesGroupLogic.getInstance().addEffect(11);
				}else
				{
					ActivitesGroupLogic.getInstance().removeEffect(11);
				}
				if(_ui.stage)
				{
					completeTask();
				}
			
			}

		}
		public function removeTask(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
			_clearStr= false ; 
			TourLog(false);
			rewardFaceAndTourFace();
			topIcon();
		}
		/**
		 * 
		 * @param e 完成任务
		 * 
		 */		
		private function finishTaskHandler(e:MouseEvent):void
		{
			if(SitAlerUI.getInstance().created == false)
			{
				SitAlerUI.getInstance().checkBtn.visible=true;
				SitAlerUI.getInstance().label2.htmlText = "下次不在提示";
				SitAlerUI.getInstance().label2.x = 152 ; 
				SitAlerLogic.getIntatic().setUIinfo("UIString_1000355",[5],FinishTask,_ui.finish_btn);
			}
		}
		private function FinishTask():void
		{
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_AFFIRM_CHARGE,18);
		}
		private function instantFinishTask():void
		{
			_tip = false;
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GIVEUP_TASK);
		}
		/**
		 * 
		 * @param e 放弃 任务
		 * 
		 */		
		private function giveUpTaskHandler(e:MouseEvent):void
		{
			if(SitAlerUI.getInstance().created == false)
			{
				SitAlerUI.getInstance().checkBtn.visible=true;
				SitAlerUI.getInstance().label2.htmlText = "下次不在提示";
				SitAlerUI.getInstance().label2.x = 152;
				SitAlerUI.getInstance().okBtn.label=StaticIni.getSwfLangStr("AlertEx_16");
				SitAlerUI.getInstance().noBtn.label=StaticIni.getSwfLangStr("AlertEx_1");
				SitAlerLogic.getIntatic().setUIinfo("UIString_1000356",[],instantFinishTask,_ui.giveup_btn);
			}
			
			_taskIsOk=true ; 
		}
		/**
		 * 
		 */		
		private function finishrwHandler(e:MouseEvent):void
		{
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_WORLD_TRAVEL_COMPLETE_TASK);
		}
		/**
		 * 游历图标特效显示
		 */
		private function topIcon():void
		{
			if(_clearStr==false&&_cdTime==0)
			{
				ActivitesGroupLogic.getInstance().addEffect(11);
			}else
			{
				
			}
		}
		/**
		 *		任务接取提示框 
		 */		
		private function taskAccept():void
		{
			if(_ui.stage)
			{
				
				if(SitAlerUI.getInstance().created == false&&_clearStr)
				{ 	
					cityName();
					SitAlerUI.getInstance().okBtn.label =StaticIni.getSwfLangStr("Common_Accept");
					SitAlerUI.getInstance().noBtn.label = StaticIni.getSwfLangStr("Common_giveup");
					SitAlerUI.getInstance().showOrHide();
					SitAlerUI.getInstance().checkBtn.visible=false;
					
					SitAlerLogic.getIntatic().setGiveUp("WttCondition_"+_taskArr[0],[_taskArr[3],_taskArr[2],_taskArr[3]],noClick,okClick,true);
					SitAlerUI.getInstance().label2.x=27;
					SitAlerUI.getInstance().label2.htmlText  = StaticIni.getSwfLangStr("Common_taskprize")+"："+StaticIni.getSwfLangStrVar("WttPrize",[StaticIni.getSwfLangStr("Capital_"+_taskArr[4]),_taskArr[5]]);
				}
			}else
			{
				
			}
			
		}
		private function okClick():void
		{
			SitAlerUI.getInstance().checkBtn.visible=true;
			SitAlerUI.getInstance().okBtn.label = StaticIni.getSwfLangStr("AlertEx_16");
			SitAlerUI.getInstance().noBtn.label = StaticIni.getSwfLangStr("AlertEx_1");
			SitAlerUI.getInstance().label2.x=152;
			SitAlerUI.getInstance().label2.htmlText="下次不再提示"
			
			if(_vipLevel>=3)
			{
				SitAlerUI.getInstance().showOrHide();
				SitAlerLogic.getIntatic().isNoClick=false; 
				
			}else
			{
				SitAlerUI.getInstance().showOrHide();
				SitAlerLogic.getIntatic().isNoClick=false; 
				_getLink(StaticIni.getSwfLangStr("Href_"+_taskArr[0].toString()));
			}
			
			rewardFaceAndTourFace();	
		}
		private function noClick():void
		{
			SitAlerUI.getInstance().okBtn.label = StaticIni.getSwfLangStr("AlertEx_4096");
			SitAlerUI.getInstance().noBtn.label = StaticIni.getSwfLangStr("AlertEx_256");
			SitAlerUI.getInstance().checkBtn.visible=false;
			SitAlerUI.getInstance().label2.htmlText = "";
			
			SitAlerLogic.getIntatic().setGiveUp("UIString_1000356",[],_noClick,_okClick,true);
		}
		private function _okClick():void
		{
			SitAlerUI.getInstance().checkBtn.visible=true;
			SitAlerUI.getInstance().okBtn.label = StaticIni.getSwfLangStr("AlertEx_16");
			SitAlerUI.getInstance().noBtn.label = StaticIni.getSwfLangStr("AlertEx_1");
			SitAlerUI.getInstance().label2.x=152;
			SitAlerUI.getInstance().label2.htmlText="下次不再提示"
			_tip=false ; 
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GIVEUP_TASK);
		}
		private function _noClick():void
		{
			SitAlerUI.getInstance().okBtn.label = StaticIni.getSwfLangStr("Common_Accept");
			SitAlerUI.getInstance().noBtn.label = StaticIni.getSwfLangStr("Common_giveup");
			SitAlerUI.getInstance().checkBtn.visible=false;
			
			SitAlerLogic.getIntatic().setGiveUp("WttCondition_"+_taskArr[0],[_taskArr[3],_taskArr[2],_taskArr[3]],noClick,okClick,true);
			SitAlerUI.getInstance().label2.htmlText  = StaticIni.getSwfLangStr("Common_taskprize")+"："+StaticIni.getSwfLangStrVar("WttPrize",[StaticIni.getSwfLangStr("Capital_"+_taskArr[4]),_taskArr[5]]);
		}
		/**
		 * 立即完成提示框
		 */		
		private function completeTask():void
		{
			if(_taskArr==null)return ; 
			if(_taskArr[2]==_taskArr[3]&&_clearStr)
			{
				rewardFaceAndTourFace();
				AlertUI.showAlert("","任务已经完成!",AlertUI.OK,returnCompele);
			}
			
		}
		private function returnCompele(ui:int , str:String,str_1:String,arr:Array=null):void
		{
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_WORLD_TRAVEL_COMPLETE_TASK);
		}
		/**
		 * 3秒提示框
		 */
		private function warning(str:String):void
		{
			NoticeUI.getInstance().showInfo(str); 
		}
		/**
		 * 
		 */
		private function cityName():void
		{
			 var value:int = loadCount%20+1;
			 var str:String =""
			 if(value>=10)
			 {
				str =  StaticIni.getSwfLangStr("Addressuistring_0"+value);
//				 value =(value).toString();
			 }else 
			 {
				 str =  StaticIni.getSwfLangStr("Addressuistring_0"+"0"+value.toString());
//				 value="0"+(value).toString();
			 }
			
			 
			 warning(StaticIni.getSwfLangStrVar("UIString_1000476",[str]))
		}
		
	}
}